package top.minuy.structure.graph.bipartition.bfs;

import top.minuy.res.graph.GraphRes;
import top.minuy.structure.graph.representations.table.Graph;

/**
 * @author Minuy
 * @time 10:58
 * @date 2021/11/20
 */
public class Test {

    public static void main(String[] args) {

        Graph graph1 = new Graph(GraphRes.G_BIPARTITION_1);
        BipartitionDetection bd1 = new BipartitionDetection(graph1);
        show("g1", bd1);

        Graph graph2 = new Graph(GraphRes.G_BIPARTITION_2);
        BipartitionDetection bd2 = new BipartitionDetection(graph2);
        show("g2", bd2);


        Graph graph3 = new Graph(GraphRes.G_BIPARTITION_3);
        BipartitionDetection bd3 = new BipartitionDetection(graph3);
        show("g3", bd3);
    }

    private static void show(String name, BipartitionDetection bd) {
        System.out.print(name+" ");
        if (bd.isBipartition()){
            System.out.println("is a BipartitionGraph.");

            System.out.print("Blue : ");
            for (int v:bd.blue()){
                System.out.print(v+" ");
            }
            System.out.println();


            System.out.print("Green : ");
            for (int v:bd.green()){
                System.out.print(v+" ");
            }
            System.out.println();
        }else {
            System.out.println("is not a BipartitionGraph.");
        }
    }
}
